//
//  PASelectCardView.m
//  PAMobileWallet
//
//  Created by Pay_SMP002 on 13-7-4.
//  Copyright (c) 2013年 平安付. All rights reserved.
//

#import "PASelectCardView.h"
#import "PABankCard.h"

#import "PASelectCardViewController.h"

@implementation PASelectCardView

- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        // Initialization code
        CGFloat x, y, w, h;
//        CGSize size = frame.size;
//        CGFloat space = 10;


        x = y = 0;
        h = 44;
        w = WIDTH_PHONE;

        titleBar = [[PATitleBar alloc] initWithFrame:CGRectMake(x, y, w, h)];
        titleBar.parentController = self;
        [titleBar setBackgroundImage:[UIImage imageNamed:@"public_navbg.png"]];
        [titleBar setLeftButtonImage:[UIImage imageNamed:@"public_navbackBT.png"] right:nil];
        [titleBar setTitle:@"选择银行卡"];
        [self addSubview:titleBar];

        y = CGRectGetMaxY(titleBar.frame);
        h = HEIGHT_CURRENT - y;
        cardsTableView = [[UITableView alloc] initWithFrame:CGRectMake(x, y, w, h)];
        cardsTableView.delegate = self;
        cardsTableView.dataSource = self;
        [self addSubview:cardsTableView];
    }
    return self;
}



#pragma mark - 
#pragma mark ================================
#pragma mark UITableViewDataSource

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return 2;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    static NSString *iden = @"PACellIden";
    UITableViewCell *cell = [tableView dequeueReusableHeaderFooterViewWithIdentifier:iden];
    if (cell == nil) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:iden];
        PABankCard *card = [[PABankCard alloc] initWithFrame:CGRectMake(10, 5, 300, 130)];
        [card setMode:BANKCARDMODE_Defalut];
        [card setTag:19284];
        [cell.contentView addSubview:card];
    }
    PABankCard *card_ = (PABankCard *)[[cell contentView] viewWithTag:19284];
    [card_ setBankCardImage:[UIImage imageNamed:@"card_card.png"]];

    return cell;
}


#pragma mark -
#pragma mark ================================
#pragma mark UITableViewDelegate
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    [self.parentController back];
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    return 140;
}


@end
